package it.datagraf.formazione.hellostruts.dao;

import it.datagraf.formazione.hellostruts.entity.Commento;

import java.sql.SQLException;
import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

public class CommentoDao implements CommentoDaoI {


	private SessionFactory sessionFactory;

    public void setSessionFactory(SessionFactory sessionFactory) {
        this.sessionFactory = sessionFactory;
    }
	
	@Override
	public List<Commento> listCommenti(int id_cv) throws SQLException {
		Session s=sessionFactory.getCurrentSession();
		return s.createQuery("from Commento where id_cv =:id_cv").setParameter("id_cv", id_cv).list();
	}

	@Override
	public void insertCommento(Commento com) throws SQLException {
		this.sessionFactory.getCurrentSession().save(com);

	}

}
